////
////  CustomRequest.m
////  StarExchange
////
////  Created by C C on 2019/1/2.
////  Copyright © 2019 C C. All rights reserved.
////
//
//#import "customRequest.h"
//
//@implementation customRequest
//
//+ (void)requestWithUrl:(NSString *)url getOrPost:(BOOL)getOrPost paramaters:(NSDictionary <NSString *, NSString *>* _Nullable)paramaters success:(CommonObjectBlock)success failure:(CommonErrorBlock)failure {
//    NSURLSession *session = [NSURLSession sharedSession];
//    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]]];
//    request.HTTPMethod = getOrPost ? @"GET" : @"POST";
//    NSString *bodyStr = @"";
//    for (NSString * key in paramaters.allKeys) {
//        [bodyStr stringByAppendingString:key];
//        [bodyStr stringByAppendingString:@"="];
//        [bodyStr stringByAppendingString:[paramaters objectForKey:key]];
//        [bodyStr stringByAppendingString:@"&"];
//    }
//    if (getOrPost) {
//        bodyStr = [NSString stringWithFormat:@"%@?%@",url, bodyStr];
//        request.URL = [NSURL URLWithString:[bodyStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];
//    } else {
//        request.HTTPBody = [bodyStr dataUsingEncoding:NSUTF8StringEncoding];
//    }
//    
//    NSURLSessionDataTask * dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
////        if (error) {
////            if ([NSThread isMainThread]) {
////                if (failure) {
////                    failure(error);
////                }
////            }
////            else {
////                if (failure) {
////                    dispatch_async(dispatch_get_main_queue(), ^(void){
////                        failure(error);
////                    });
////                }
////            }
////        } else {
////            if (data) {
//                NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
////                if ([NSThread isMainThread]) {
////                    if (success) {
////                        success(dic);
////                    }
////                }
////                else {
////                    if (success) {
////                        dispatch_async(dispatch_get_main_queue(), ^(void){
////                            success(dic);
////                        });
////                    }
////                }
////            } else {
////                if ([NSThread isMainThread]) {
////                    if (success) {
////                        success([NSDictionary new]);
////                    }
////                }
////                else {
////                    if (success) {
////                        dispatch_async(dispatch_get_main_queue(), ^(void){
////                            success([NSDictionary new]);
////                        });
////                    }
////                }
////            }
////        }
//    }];
//    [dataTask resume];
//}
//
//@end
